﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;

namespace YJKRevitKernel.ElementFilterUtility
{
	public class SingleGridFilter : ISelectionFilter
	{
		public bool AllowElement(Element elem)
		{
			if (typeof(Grid) == elem.GetType())
			{
				foreach (Element element in new FilteredElementCollector(elem.Document).OfClass(typeof(MultiSegmentGrid)).ToElements())
				{
					IEnumerator<ElementId> enumerator2 = ((MultiSegmentGrid)element).GetGridIds().GetEnumerator();
					{
						while (enumerator2.MoveNext())
						{
							if (enumerator2.Current.Equals(elem.Id))
							{
								return false;
							}
						}
					}
				}
				return true;
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ pos)
		{
			return false;
		}
	}
}
